package svgedit.gui;

import java.awt.Shape;
import java.awt.Stroke;
import svgedit.svg.SVGElement;

/**
 * This stroke adds the little control points (square boxes) around an element
 * It gets the appropriate markers for the element being selected and constructs
 * the control points to be placed It implements a stroke and should be treated
 * as a stroke normally is when applying to the graphics functions setStroke()
 * 
 * @author SARJ
 * 
 */
public class ControlPointsStroke implements Stroke
{
	float radius; // how big the control point markers should be

	// Reference to view
	private SVGElement element;

	/**
	 * Create the stroke on the element
	 * 
	 * @param radius
	 *            The size of the little squares
	 * @param elem
	 *            The element to select
	 */
	public ControlPointsStroke(float radius, SVGElement elem)
	{
		this.element = elem;
		this.radius = radius;
	}

	@Override
	public Shape createStrokedShape(Shape shape)
	{

		// Get element selelction stroke
		Shape stroke = this.element.getSelectionStroke();

		// Add the markers to the viewport for this element
		Frame.getFrame().getView().getMarkers()
				.addAll(this.element.getMarkers());

		return stroke;

	}
}
